package com.wswy.wyjk.ui.share;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetDialog;
import android.view.View;

import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
import com.wswy.wyjk.R;


/**
 * Created by zl on 2017/12/18.
 */

public class ShareDialog extends BottomSheetDialog implements View.OnClickListener {
  /**
   * 好友
   */
  public static final int TYPE_WX_FRIEND = SendMessageToWX.Req.WXSceneSession;

  /**
   * 朋友圈
   */
  public static final int TYPE_WX_TIMELINE = SendMessageToWX.Req.WXSceneTimeline;

  private OnChooseShareTypeCallback mCallback;

  public ShareDialog(@NonNull Context context, OnChooseShareTypeCallback callback) {
    super(context);
    mCallback = callback;
    setContentView(R.layout.dialog_share);

    findViewById(R.id.share_timeline).setOnClickListener(this);
    findViewById(R.id.share_friend).setOnClickListener(this);
    findViewById(R.id.tv_cancel).setOnClickListener(this);


  }

  public void onClick(View view){
    int id = view.getId();
    if(id == R.id.share_timeline){
      //微信朋友圈
      if(mCallback != null){
        mCallback.onChooseType(TYPE_WX_TIMELINE);
      }
    }else if(id == R.id.share_friend){
      //微信好友
      if(mCallback != null){
        mCallback.onChooseType(TYPE_WX_FRIEND);
      }
    }else if(id == R.id.tv_cancel){
      //取消
    }

    dismiss();
  }


  public interface OnChooseShareTypeCallback{
    void onChooseType(int shareType);
  }

}
